/**
 * 监听事件触发次数，来优化请求次数
 * 
 * 优点：避免多次请求对流量的浪费，减轻了服务器对统计请求的压力
 */
var LogPack = function() {
    var data = [],
        MaxNum = 10,
        itemSplitStr = '|',
        keyValueSplitStr = '*',
        img = new Image();
    function sendLog() {
        var logStr = '',
            fireData = data.splice(0, MaxNum);
        for(var i = 0, len = fireData.length; i < len; i++) {
            logStr += 'log' + i + '=';
            for (var j in fireData[i]) {
                logStr += j + keyValueSplitStr + fireData[i][j];
                logStr =+ itemSplitStr;
            }
        logStr = logStr.replace(/\|$/, '') + '$';
        }
        logStr += 'logLength=' + len;
        img.src = 'a.gif?' + logStr;
    }
    return function(param) {
        if (!param) {
            sendLog();
            return;
        }
        data.push(param);
        data.length >= MaxNum && sendLog();
    }
}
